<?php include("include/textcenter.php"); ?>
<?php include("include/db.php"); ?>
<html>
<head>
<meta name="description" content="Admin<?php echo $tagdescription?>">
<meta name="keywords" content="<?php echo $tagkeywords?> Main">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><?php echo $tagtitle?></title>

<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
<LINK rel="StyleSheet" href="include/css_classes.css" type="text/css">

</head>



<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" link="#0000FF" vlink="#800080" alink="#FF0000" bgcolor="#FFFFFF">
<!-- -------------------Header---------------------------- -->
<?php include("include/header.php"); ?>
<!-- -------------------End Header---------------------------- -->


<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="12%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="200" height="1"></td>
		<td width="1%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
		<td width="86%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
	</tr>	
	<tr>
		<!-- ///////////////////Begin Leftmenu/////////////////// -->
		<td width="12%" valign="top" bgcolor="#FFFFFF">
		<?php include("include/leftmenu.php"); ?>
		</td>
		<!-- ///////////////////End Leftmenu/////////////////// -->
		
		<td width="1%" valign="top" background="public/images/homepage/16.gif">&nbsp;</td>
		<td width="86%" valign="top">
	<br>
<!-- -------------------Begin Body---------------------------- -->
<p class="title16B">&nbsp;Mapping category product &nbsp;<a href="Category_product_add.php">Add +</a></p>
<?php
$page_name="category_product_list.php"; //  If you use this code with a different page ( or file ) name then change this 

//$start=$_GET['start'];
if(empty($_GET['start'])) 
$start=0;
    //echo "No GET variables"; 
else 
$start=$_GET['start'];
  //  print_r($_GET); 
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0); 
$limit = 90;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 

/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query2=" SELECT cp.*, c.admin_title FROM vnf_category_product cp 
left join vnf_category c on cp.CategoryID = c.category_id 
where admin_title is not null";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////
?>


<?php
		/////////////////////////////// 
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging

//-------------------------------------------------page------------------------------------------------------------
/////////////// Start the bottom links with Prev and next link with page numbers /////////////////
echo "<table  width='85%'><tr><td>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0) { 
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 
} 
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////

$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}        /// Current page is not displayed as link and given font color red
$l=$l+1;
}

///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume) { 
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} 

echo "</td></tr></table>";
}// end of if checking sufficient records are there to display bottom navigational link. 
//---------------------------------------------end page-----------------------------------------------------------
	?>
    <table style="font-size:10pt; 1px;width:86%; bgcolor:#E0E0E0" >
				<tr bgcolor="#0C0C0C" style=" font-weight:bold; border:#000000 solid; ">						
					<td style="padding:4px;color:#FFF">Category</td>
                    <td style="padding:4px;color:#FFF">Product</td>
					<td style="padding:4px;color:#FFF" align="center" width="70px" colspan="2"></td>
				</tr>
<?php 
$bgcolor ="#FDE8F2";
/*$rs_result = mysql_query("SELECT COUNT(CPID) FROM vnf_category_product");
$row = mysql_fetch_row($rs_result); 
$total_records = $row[0]; 
$total_pages = ceil($total_records / 30); 
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$start_from = ($page-1) * 30; */
$rs_result = mysql_query("SELECT cp.*, c.admin_title FROM vnf_category_product cp 
left join vnf_category c on cp.CategoryID = c.category_id 
where admin_title is not null
order by  admin_title ASC  limit $eu, $limit");
//left join vnf_product p on cp.ProductID = p.ProductNo 
while ($row = mysql_fetch_assoc($rs_result))
 {
$CategoryID = $row['CategoryID'];
$ProductID = $row['ProductID'];
$Category = $row['admin_title'];
//$product = $row['Product'];
//$Product = $row['Product'];
$id = $row['CPID'];
//echo $Category, $Product;
?> 
    	<tr style=" border:#000000 solid">
				<td style="background-color: <?php echo "#".$bgcolor?>;">
                    <a href="category_product_detail.php?id=<?php echo $id; ?>"><?php echo $Category; ?></a>
				</td>
				<td style="background-color: <?php echo "#".$bgcolor?>;">
                    <a href="category_product_detail.php?id=<?php echo $id; ?>"><?php echo $ProductID;?></a>
				</td>
				<td align="center" style="background-color: <?php echo "#".$bgcolor?>;">
					<a style="color:#0033FF;" href="category_product_update.php?id=<?php echo $id ?>">
						Update
					</a>
				</td>
				<td align="center" style="background-color: <?php echo "#".$bgcolor?>;">
					<a onclick="confirm('Do you really want to delete?')" href="category_product_delete.php?id=<?php echo $id ?>">
						Delete
					</a>
				</td>
		</tr>
        	<?php 
	if ($bgcolor =="fde8f2")
 $bgcolor ="FFFFFF";
else  $bgcolor ="fde8f2";
}; 
?>
<div style="width: 100%; margin-bottom: 10px;">	
<?php

for ($i=1; $i<=$total_pages; $i++) { 
?>
    <span style='padding:5px'><a href='category_product_list.php?page=<?=$i?>'><?=$i?></a></span>
<?php    
}; 

?>	
</div>
</table>
<br />




<!-- -------------------End Body---------------------------- -->

&nbsp;</td>
	</tr>

</table>
</div>
<!-- ----------------------------------------------- -->
<!-- \\\\\\\\\\\\\\\\\\\\\Begin Footer\\\\\\\\\\\\\\\\\\\\\ -->
<?php include("include/footer.php"); ?>
<!-- \\\\\\\\\\\\\\\\\\\\\End Footer\\\\\\\\\\\\\\\\\\\\\ -->
</body>

</html>